package com.genius.util;

import java.text.SimpleDateFormat;
import java.util.Date;

public class DateUtil
{
    /**
     * 
     */
    public static final String FORMAT = "dd-MM-yyyy";
    
    /**
     * 
     */
    public static final SimpleDateFormat DATE_FORMATTER = new SimpleDateFormat(FORMAT);
    
    /**
     * 
     * @param date
     * @return
     */
    public static String dateToString(Date date) {
        
        String str = null;
        if(date != null) {
            str = DATE_FORMATTER.format(date);
        }
        return str;
    }
    
    /**
     * 
     * @param value
     * @return
     */
    public static Date stringToDate(String value) {
        System.out.println( "Date = " + value);
        Date date = null;
        try {
            if(value != null && value.length() > 0 ) {
                date = DATE_FORMATTER.parse(value);    
            }
        } catch (Exception e) {
              e.printStackTrace();  
        }
        System.out.println( "Returning Date = " + date);
        return date;
    }

}
